﻿using InnoWeb.CEND.BL.Infrastructure;
using InnoWeb.CEND.Core.Model.iThink;
using InnoWeb.CEND.Data;
using InnoWeb.CEND.Data.Infrastructure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace InnoWeb.CEND.BL.Service.iThink
{
    public class iThinkContentService: IService<iThinkContents>
    {
        private readonly GenericRepository<iThinkContents> _iThinkContentRepository;
        private readonly IUnitOfWork _unitOfWork;

        public iThinkContentService(IUnitOfWork unitOfWork, GenericRepository<iThinkContents> iThinkContentRepository)
        {
            this._iThinkContentRepository = iThinkContentRepository;
            this._unitOfWork = unitOfWork;
        }

        public IQueryable<iThinkContents> GetAllElements()
        {
            return _iThinkContentRepository.GetAll();
        }

        public iThinkContents GetElementById(int id)
        {
            return _iThinkContentRepository.GetById(id);
        }

        public void CreateElement(iThinkContents entity)
        {
            _iThinkContentRepository.Insert(entity);
        }

        public void UpdateElement(iThinkContents entity)
        {
            _iThinkContentRepository.Update(entity);
        }

        public void DeleteElement(int id)
        {
            _iThinkContentRepository.Delete(id);
        }

        public void SaveChanges()
        {
            _unitOfWork.SaveChanges();
        }
    }
}
